#ifndef __AUDIO_ENCODER_H__
#define __AUDIO_ENCODER_H__
#include "stdint.h"
#include "y_ringbuf.h"
#include "os_task.h"
#include "os_mem.h"
#include "adpcm-pcm.h"

//FIXED_POINT HAVE_CONFIG_H DISABLE_FLOAT_API DISABLE_VBR

extern uint16_t task_id_audio_encode;
extern ima_adpcm_state_t* state;

#define ENCODER_EVENT (0)

#define ENCODER_REMAIN_EVENT (1)

typedef enum
{
		ENCODER_STATE_IDLE,
    ENCODER_STATE_BUSY,
    ENCODER_STATE_MAX,
}Current_Encoder_Status_t;

typedef struct
{
	uint32_t current_frame_index;
	uint32_t current_send_frame_index;
	
	Current_Encoder_Status_t status;
	Current_Encoder_Status_t status1;
	RINGBUF_st *pcm_in_ringbuffer;
	RINGBUF_st *encoder_out_ringbuffer;

}Audio_Encode_t;	


#define AUDIO_FRAME_LEN    64
#define RINGBUFFER_LEN		 1024*5


void audio_encoder_init(void);

void audio_encoder_start(void);

void audio_encoder_stop(void);

bool get_audio_encoder_is_busy(void);
bool get_num_audio_encoder_is_busy(uint8_t num);

bool audio_encoder_src_input(uint8_t*data,uint16_t len);
uint16_t get_audio_encoder_valid_size();

void msg_post_encode_handler();
void msg_send_remain_event();

void audio_encode_current_frame_add();
uint32_t audio_encode_get_current_frame();
void audio_encode_current_frame_reset();

void audio_encode_current_send_frame_add();
uint32_t audio_encode_get_current_send_frame();
void audio_encode_current_send_frame_reset();


void audio_write_to_ringbuffer(uint8_t *data,int len);
uint16_t audio_read_to_ringbuffer(uint8_t *read,int len);


void ringbuffer_reset();


uint16_t get_speak_len();


#endif